<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <script src="/html/js/util.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
    <title>发表新帖</title>
</head>
<script>
    let userId;
    let themeId;
    window.onload = function () {
        userId = getQuery("userId");
        themeId = getQuery("themeId");
        console.log(userId + "   " + themeId);
        //设置当前板块跳转连接
        $("nowMain").href = "/html/main/main.html?themeId=" + themeId;
    }

    async function addMC() {
        let params = {
            mcTitle: $("mcTitle").value,
            mcContent: $("mcContent").value,
            userId: userId,
            themeId: themeId
        }

        let result = await ajaxGet("/mainContent/addMC", params);
        if (result == "ok") {
            location.href = "/html/main/main.html?themeId=" + themeId;
        }
    }
</script>
<body>
<div>
    <ul class="layui-nav" style="display: flex;justify-content: center">
        <li class="layui-nav-item"><a href="/html/theme/theme.html">首页</a></li>
        <li class="layui-nav-item"><a id="nowMain">当前板块</a></li>
        <li class="layui-nav-item layui-this"><a href="">发布新帖</a></li>
        <li class="layui-nav-item"><a href="javascript:outAccount()">退出</a></li>
        <li class="layui-nav-item"><a href="">管理</a></li>
        <li class="layui-nav-item"><a href="">风格</a></li>
    </ul>
</div>
<div style="display: flex;justify-content: center">
    <div style="width: 50%">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block" style="margin-bottom: 50px;margin-top: 50px">
            <input type="text" name="title" id="mcTitle" required lay-verify="required" placeholder="请输入标题"
                   autocomplete="off"
                   class="layui-input">
        </div>

        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea name="desc" id="mcContent" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
        <div style="display: flex;justify-content: center">
            <button type="button" class="layui-btn" onclick="addMC()">发表新帖</button>
        </div>
    </div>
</div>
</body>
</html>